#ifndef UTI_BARSERIES_BROAD_H_
#define UTI_BARSERIES_BROAD_H_
#pragma once
#include "sys_config.h"
#include "uti_bar.h"




class BarSeries_broad
{
public:

	BarSeries_broad(BarInfo* pbarinfo, unsigned int sersize, void (*p)(), BarData* pstart, unsigned int* pindex);

	~BarSeries_broad();

	bool Addtick(MarketData* tick);

	void SetBarend()
	{
		m_pcur->isend = true;
	}

	bool GetBarend(){ return m_pcur->isend;}

private:

	void SetSystime(SYSTEMTIME* ptm, const char* pdate, const char* ptime, int millisec);
	void SetSystime(SYSTEMTIME* ptm, const char* ptime, int millisec);


	void UpdateBar(MarketData* tick, bool updatestarttm, SYSTEMTIME* pstarttm);

	LONGLONG GetStartspan(SYSTEMTIME& ticksys);//not used for tick type

	bool SatisfyTime(SYSTEMTIME& tm);

public:
	//bar basic info
	BarSerInfo m_serinfo;//basic bar information including type and count, for example 30 minutes bar, m_barinfo.type = min, m_barinfo.cnt =30. 

	BarData* m_pcur;//point to last bar of series, this bar may not complete(could be control by value of BarData.isend)

	unsigned int* m_pindex;// if m_pcur is avaliable, its value is >=0. ;
	// used to find other avaliable BarDate before m_pcur, for example used to caculate MA(5)
	//unsigned int m_mqindex;

	unsigned int m_dbindex;

private:
	bool notfirstbar;				


	WORD m_year;
	WORD m_month;
	WORD m_day;

	bool bCommidity;

};



#endif